$(function() {
    var form = layui.form
    var layer = layui.layer
        // 注册请求
    form.on('submit(form-box)', function(data) {

        console.log(data);
        var Sum = data.field;
        $.ajax({
            method: 'post',
            url: "/api/auth/login",
            data: Sum,
            dataType: "json",
            success: function(res) {
                // 配置弹出提示
                if (res.errmsg) {
                    return layer.msg(res.message)
                }
                localStorage.setItem('token', res.data.token)
                layer.msg('登录成功')
                location.href = '/user.html'
            }

        })

    });

})